package ${package.Controller};


import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartStatus.core.util.R;

<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
/**
* ${table.comment?uncap_first} Controller
* @author ${author}
* @since ${date}
*/
<#if restControllerStyle>
@RestController
@Slf4j
@Api(value = "${table.controllerName}",tags = "${table.entityName}管理")
@AllArgsConstructor
<#else>
@Controller
</#if>
@RequestMapping("/${table.entityName}")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    private final ${table.entityName}Service ${table.entityName?uncap_first}Service;

    /**
    * 分页数据
    */
    @ApiOperation(value = "公共参数分页数据")
    @GetMapping("/page")
    public R ${table.entityName?uncap_first}Page(Page<${table.entityName}> page, ${table.entityName} ${table.entityName?uncap_first} ) {
        QueryWrapper<${table.entityName}> query = Wrappers.query();
        return R.ok( ${table.entityName?uncap_first}Service.page(page,query));
    }


    /**
    * 列表数据
    */
    @ApiOperation(value = "公共参数列表")
    @GetMapping("/list")
    public R ${table.entityName?uncap_first}List() {
        return R.ok( ${table.entityName?uncap_first}Service.list());
    }


    /**
    * 编辑数据
    */
    @ApiOperation(value = "编辑公共参数")
    @ApiImplicitParam(name = "${table.entityName}", value = "${table.entityName}实体", required = true, dataType = "${table.entityName}")
    @PutMapping("/edit")
    public R ${table.entityName?uncap_first}Update(@RequestBody  ${table.entityName} ${table.entityName?uncap_first}) {
        return R.ok( ${table.entityName?uncap_first}Service.updateById(${table.entityName?uncap_first}));
    }


    /**
    * 删除数据
    */
    @ApiOperation(value = "删除公共参数")
    @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Integer")
    @DeleteMapping("/{id}")
    public R ${table.entityName?uncap_first}Delete(@PathVariable Integer id){
        return R.ok( ${table.entityName?uncap_first}Service.removeById(id));
    }

    /**
    * 添加数据
    */
    @ApiOperation(value = "添加公共参数")
    @ApiImplicitParam(name = "${table.entityName}", value = "${table.entityName}实体", required = true, dataType = "${table.entityName}")
    @PostMapping("/add")
    public R ${table.entityName?uncap_first}Insert(@RequestBody  ${table.entityName} ${table.entityName?uncap_first}){
        return R.ok( ${table.entityName?uncap_first}Service.save(${table.entityName?uncap_first}));
    }
}
</#if>
